package logic;

/**
 * 配置信息(单例模式)
 * @author 骆焕
 *
 */
public class ConfigInfo {
	
	// 懒汉式对象
	private static ConfigInfo configInfo = null;
	private ConfigInfo() {
		
	}

	/**
	 * 广播推送间隔时间
	 */
	public static final String KEY_PUSH_INTERVAL = "pushInterval";
	public int pushInterval;
	/**
	 * 文本框记录行数
	 */
	public static final String KEY_JTEXT_ROWS = "jTextRows";
	public int jTextRows;
	/**
	 * 应答帧
	 */
	public static final String KEY_RESPONSE_FRAME = "responseFrame";
	public String responseFrame;
	/**
	 * 大小端
	 */
	public static final String KEY_BYTE_ORDER = "byteOrder"; 
	public int byteOrder;
	/**
	 * 编解码方式
	 */
	public static final String KEY_ENCODER_STYLE = "encoderStyle"; 
	public int encoderStyle;
	/**
	 * 服务端口号
	 */
	public static final String KEY_SERVER_PORT = "serverPort";
	public int serverPort;
	/**
	 * 推送消息
	 */
	public static final String KEY_PUSH_MESSAGE = "pushMessage";
	public String pushMessage;
	
	/**
	 * 获取单例对象
	 * @return
	 */
	public static ConfigInfo getInstance() {
		if (configInfo == null) {
			configInfo = new ConfigInfo();
			configInfo.jTextRows = Integer.valueOf(PropHelper.getPropValue(KEY_JTEXT_ROWS));
			configInfo.responseFrame = PropHelper.getPropValue(KEY_RESPONSE_FRAME);
			configInfo.byteOrder = Integer.valueOf(PropHelper.getPropValue(KEY_BYTE_ORDER));
			configInfo.encoderStyle = Integer.valueOf(PropHelper.getPropValue(KEY_ENCODER_STYLE));
			configInfo.pushInterval = Integer.valueOf(PropHelper.getPropValue(KEY_PUSH_INTERVAL));
			configInfo.serverPort = Integer.valueOf(PropHelper.getPropValue(KEY_SERVER_PORT));
			configInfo.pushMessage = PropHelper.getPropValue(KEY_PUSH_MESSAGE);
		}
		return configInfo;
	}
}
